package com.dormitory.service.impl;

import com.dormitory.dao.StudentDao;
import com.dormitory.dao.impl.StudentDaoImpl;
import com.dormitory.model.Student;
import com.dormitory.service.StudentService;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    private StudentDao studentDao;

    public StudentServiceImpl() {
        this.studentDao = new StudentDaoImpl();
    }

    @Override
    public boolean addStudent(Student student) {
        return studentDao.save(student);
    }

    @Override
    public boolean updateStudent(Student student) {
        return studentDao.update(student);
    }

    @Override
    public boolean deleteStudent(Integer studentId) {
        return studentDao.delete(studentId);
    }

    @Override
    public Student getStudentById(Integer studentId) {
        return studentDao.findById(studentId);
    }

    @Override
    public List<Student> getAllStudents() {
        return studentDao.findAll();
    }

    @Override
    public List<Student> searchStudents(String condition) {
        return studentDao.findByCondition(condition);
    }
} 